using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BigFishBoom : MonoBehaviour
{
    // Start is called before the first frame update
    public GameObject boomobject;
    Transform ttransform;
    EnemyAttack attack;
    float CDtime;
    public float CD;
    public int boomtime;
    void Start()
    {
        ttransform = GetComponent<Transform>();
        attack = transform.parent.GetComponentInChildren<EnemyAttack>();
        CDtime = 5;
    }
    private void Update()
    {
        if (CDtime > 0)
        {
            CDtime -= Time.deltaTime;
        }
        else
        {
            boom();
            CDtime = CD;
        }
    }
    // Update is called once per frame
    void boom()
    {
        Debug.Log("Boom!");
        Vector3 position = ttransform.position;
        position.y = 5;
        for (int i = 1; i <= boomtime; i++)
        {
            
            Instantiate(boomobject, position, Quaternion.identity);
            position.x -= attack.face*12;
        }
        position = ttransform.position;
        position.y = 5;
        for (int i = 1; i <= boomtime; i++)
        {

            Instantiate(boomobject, position, Quaternion.identity);
            position.x += attack.face * 12;
        }
    }
}
